<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  
  <meta name="generator" content="Hugo 0.98.0" />

  
  <meta name="description" content="走在通往幸福的路上">
  

  
  <link rel="apple-touch-icon" sizes="180x180" href="https://blog.v5u.win/apple-touch-icon.png">

  
  <link rel="icon" type="image/png" sizes="32x32" href="https://blog.v5u.win/favicon-32x32.png">

  
  <link rel="icon" type="image/png" sizes="16x16" href="https://blog.v5u.win/favicon-16x16.png">

  
  <link rel="manifest" href="https://blog.v5u.win/site.webmanifest">

  
  <link rel="mask-icon" href="https://blog.v5u.win/safari-pinned-tab.svg" color="">

  <meta name="msapplication-TileColor" content="">

  <meta name="theme-color" content="">

  
  <link rel="stylesheet" href="https://blog.v5u.win/css/bootstrap.min.css" />

  
  <title>压力测试 ab wrk | 为吾优</title>
  

  <style>
body {
  min-width: 300px;
}

.custom-navbar {
  margin-bottom: 1em;
  height: 60px;
}

.custom-navbar a {
  display: inline-block; 
  padding: 18px 0;
  margin-right: 1em; 
  font-weight: bold; 
}

.custom-navbar a:hover,
.custom-navbar a:focus {
  text-decoration: none; 
}

@media print {
  .custom-navbar {
    display: none;
  }
}

article {
  padding-bottom: 1em;
}

img {
  max-width: 100%;
}


body {
  background-color: #fff;
}



body {
  color: #212529;
}



a {
  color: #007bff;
}



a:hover,
a:focus {
  color: #0056b3;
}



.custom-navbar {
  background-color: #212529;
}



.custom-navbar a {
  color: rgba(255,255,255,.75);
}



.custom-navbar a:hover,
.custom-navbar a:focus {
  color: rgba(255,255,255,1);
}



.container {
  max-width: 800px;
}





</style>
</head>

<body>
  <nav class="custom-navbar">
  <div class="container">
    
    <a href="/">文章</a>
    
    <a href="/tags/">标签</a>
    
    <a href="/about/">关于</a>
    
    <a href="/index.xml">RSS</a>
    
  </div>
</nav>
  
  <div class="container">
    <article>
      <h1>压力测试 ab wrk</h1>
<p>
  <small class="text-secondary">
  
  
  2019-03-12
  </small>
  
</p>
<p>压力测试 ab wrk</p>
<h4 id="ab为apache内置">ab为Apache内置</h4>
<p>ab -n1000 -c10 http://localhost:8080/</p>
<p>1000次请求 10个并发,分析 Requests per second 字段</p>
<pre><code>Server Software:        Iris:
Server Hostname:        localhost
Server Port:            8080
Document Path:          /
Document Length:        5368 bytes
Concurrency Level:      10
Time taken for tests:   0.758 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      5580884 bytes
HTML transferred:       5368000 bytes
Requests per second:    1318.86 [#/sec] (mean)
Time per request:       7.582 [ms] (mean)
Time per request:       0.758 [ms] (mean, across all concurrent requests)
Transfer rate:          7187.91 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       2
Processing:     1    7  11.5      4     124
Waiting:        1    7  11.4      3     123
Total:          1    7  11.5      4     125
Percentage of the requests served within a certain time (ms)
  50%      4
  66%      6
  75%      8
  80%      9
  90%     14
  95%     22
  98%     43
  99%     57
 100%    125 (longest request)
</code></pre>
<h4 id="wrkbrew-install-wrk">wrk：brew install wrk</h4>
<p>wrk -c10 -t10 -d5 http://localhost:8080/</p>
<p>10个连接 10个线程，持续5秒，分析 Requests/sec 请求次数/秒</p>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<p>简单高效，ab默认短连接(http1.0)，wrk默认长连接</p>
<p>分析结果：</p>
<p>– 减少数据库依赖</p>
<p>– 模板尽量少使用动态数据</p>

    </article>
  </div>

  
  
  

  
</body>

</html>